module Customer (
Customer, -- CONSTRUCTOR: MkCustomer CustomerName [PerformedHaircut]
createCustomer, -- createCustomer :: CustomerName -> Customer
addPerformedHaircut, -- addPerformedHaircut :: Customer -> PerformedHaircut -> Customer
getCustomerName, -- getCustomerName :: Customer -> CustomerName
getHisPerformedHaircuts, -- getHisPerformedHaircuts :: Customer -> [PerformedHaircut]
getPerformedHaircutsAsStrings, -- :: Customer -> [String]
setCustomerName, -- :: Customer -> CustomerName -> Customer
) where

{-
AUTOR:Gaston Charkiewicz
DESCRIPCION: tipo de datos que representa un cliente de la peluquería. 
OBSERVACIONES: posee una lista de cortes que se ha hecho previamente. Al crearse el cliente,
esta lista se encuentra vacía.
-}

import PerformedHaircut
import Haircut

data Customer = MkCustomer CustomerName [PerformedHaircut]
type CustomerName = String

createCustomer :: CustomerName -> Customer
createCustomer aName = MkCustomer aName []

--Decidi no darle un string porque de eso se encarga el controlador, si me meto con eso
--por ahi estaria haciendo en el modelo cosas que al mismo no le corresponderia hacer.
addPerformedHaircut :: Customer -> PerformedHaircut -> Customer
addPerformedHaircut (MkCustomer hisName []) pHaircutToAdd   = MkCustomer hisName [pHaircutToAdd]
addPerformedHaircut (MkCustomer hisName (xs)) pHaircutToAdd = MkCustomer hisName (pHaircutToAdd:xs)

--Decidi que no devuelva el string, porque eso le corresponde al controlador
getCustomerName :: Customer -> CustomerName
getCustomerName (MkCustomer theName _) = theName

getHisPerformedHaircuts :: Customer -> [PerformedHaircut]
getHisPerformedHaircuts (MkCustomer _ hisList) = hisList

setCustomerName :: Customer -> CustomerName -> Customer
setCustomerName (MkCustomer _ phc) newName = MkCustomer newName phc
----------------------------------------------
----------SOME KIND OF CONTROLLER------------
---------------------------------------------
getPerformedHaircutsAsStrings :: Customer -> [String]
getPerformedHaircutsAsStrings (MkCustomer aName [])      = []
getPerformedHaircutsAsStrings (MkCustomer aName (ph:phs)) = (getHaircutName (hisKindOfHaircut ph)):(getPerformedHaircutsAsStrings (MkCustomer aName phs))

